/*
 * =====================================================================================
 *
 *       Filename:  testthread.cc
 *
 *    Description:  Testing pthread wrapper
 *
 *        Version:  1.0
 *        Created:  12-04-25 02:19:33 PM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  YOUR NAME (), 
 *   Organization:  
 *
 * =====================================================================================
 */
#include <stdlib.h>
#include "thread.h"
#include <iostream>
#include "mutex.h"

using namespace std;

int s=0;

Mutex mx;

class ThreadTest: public Thread{
public:
	ThreadTest(int i=0): Thread(i){};

	virtual void run() {
		for(int i=0; i< 1000000; ++i){
			mx.lock();
			s+=1;	
			mx.unlock();
		}
	};
};

int main() {
	ThreadTest t1(1), t2(2);

	t1.start();
	t2.start();

	t1.join();
	t2.join();

	cout << " s = " <<s<<endl;

	return 0;
}

